//
// Created by hkkzzxz on 24-9-4.
//

#ifndef YUNSHI_BASECONTROLLER_H
#define YUNSHI_BASECONTROLLER_H

// 控制类中的服用代码类，解析Json对象，设置HTTP相应内容等

#include <json/json.h>

#include "HttpConnection.h"

class BaseController {
protected:
    // 日志对象
    LogManager *logManager = LogManager::getInstance();
    std::shared_ptr<spdlog::logger> consoleLogger = logManager->getConsoleLogger();
    std::shared_ptr<spdlog::logger> fileLogger = logManager->getFileLogger();

    // 解析请求体
    bool parseRequestBody(const http::request<http::dynamic_body> &httpRequest, Json::Value &root);

    // 设置HTTP响应内容
    void setHttpResponse(http::response<http::dynamic_body> &httpResponse, const Json::Value &root);
};


#endif //YUNSHI_BASECONTROLLER_H
